<template>
  <div>
    <!-- 人员选择\代码搜索 -->
    <TopFilter :list="topFilterInit" :cols="3" :collapse="collapse" labelWidth="90" @filterChange="changeHandle"></TopFilter>
    <!-- table -->
    <FilterTable
      height="250"
      ref="listModal"
      :columns="columns"
      :selectionType="selectType"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :onColumnsChange="columns => (this.columns = columns)"
      :onRowSelectChange="selectChange"
      columnsRef="cms-common_user_index_01"
    ></FilterTable>
    <div class="dialogBottmView">
      <el-button @click="closeDialog">取 消</el-button>
      <el-button @click="saveDialog" type="primary">{{ submit }}</el-button>
    </div>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { getUser } from '@/api/cms-common/user';
export default {
  mixins: [dictionary],
  props: {
    submit: {
      type: String,
      default: '确定'
    },
    selectType: {
      type: String,
      default: 'single' //multiple-多选，single-单选
    }
  },
  data() {
    return {
      visible: false,
      visibleDrawer: false,
      collapse: false,
      infoId: null,
      topFilterInit: this.topFilterInitFun(),
      flterValue: {}, //参数
      columns: this.creatHeader(),
      fetchApi: getUser,
      fetchParams: { dataType: 10461003 }, //ipa 接口
      selectedRows: [] //选中经销商
    };
  },
  methods: {
    //搜索数据
    topFilterInitFun() {
      return [
        { type: 'INPUT', label: '员工姓名', fieldName: 'employeeName', placeholder: '请输入', initialValue: '' },
        { type: 'INPUT', label: '手机', fieldName: 'mobilePhone', placeholder: '请输入', initialValue: '' }
      ];
    },
    //搜索获取数据
    changeHandle(val) {
      
      // this.fetchParams = val;
      if(this.$parent != undefined ){
         if(this.$parent.$parent != undefined ){
               if(this.$parent.$parent.$parent != undefined ){
                 if(this.$parent.$parent.$parent.appName==='qyjl'){
                   val.dataSources='10451002';
                 }
         }
         }
      }


      this.fetchParams = Object.assign({}, val);
      console.log(val);
    },
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '事业部', dataIndex: 'orgName', width: '200px', sorter: true },
        { title: '员工代码', dataIndex: 'employeeNo', sorter: true },
        { title: '员工姓名', dataIndex: 'employeeName', sorter: true },
        {
          title: '性别',
          dataIndex: 'gender',
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.gender, '1002')}</span>;
          }
        },
        { title: '手机', dataIndex: 'mobilePhone', sorter: true },
        { title: '身份证号码', dataIndex: 'certificateId', width: '200px', sorter: true }
      ];
    },
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },
    //保存
    saveDialog() {
      this.$emit('close', { visible: false, data: this.selectedRows, type: 'back' });
    },
    //取消操作
    closeDialog() {
      // this.$emit('close', { visible: false ,"data":this.selectedRows,type:'close'});
      this.$emit('close', { visible: false, type: 'close' });
    }
  }
  // mounted() {
  //   this.BaseTable = this.$refs.listModal.$refs.pageTable;
  // }
};
</script>

<style lang="less" scoped></style>
